

<template>
<div>
     <!-- <Button type="primary" @click="modal1 = true">Display dialog box</Button> -->
     <Modal v-model="mode" width="60%"  title="红枣质押-详情" @change="testChange"  @on-cancel="cancel">
         <Row>
          <Form ref="EntryOrderData"  :model="EntryOrderData"  :rules="ruleInUser" :label-width="100">
                <div style="width:90%;height:auto;margin:0 auto;">
                     <Col span="24">
                       <FormItem label="单据号：" prop="Id">
                          <Input v-model="EntryOrderData.OrderNo" class="orders_disabled" placeholder="请输入用户编号" disabled />
                       </FormItem>
                       <FormItem label="客户名称：" prop="ClassName">
                        <label slot="label">客户名称：</label>
                        <Input v-model="EntryOrderData.CustomerName" class="orders_disabled_custom" placeholder="请输入客户名称"  disabled/>
                     </FormItem> 
                     </Col>
                    <Col span="12"> 
                      <FormItem label="毛重时间：" prop="TypeName">
                        <Input v-model="EntryOrderData.RoughWeightTime" class="orders_disabled" placeholder="请输入申请时间"  disabled/>
                      </FormItem> 
                      <FormItem label="毛重：" prop="UpdateTime">
                          <InputNumber v-model="EntryOrderData.RoughWeight" class="orders_disabled" placeholder="请输入质押件数"  disabled/>
                      </FormItem> 
                      <FormItem label="净重：" prop="UpdateTime">
                          <InputNumber v-model="EntryOrderData.NetWeight" class="orders_disabled" placeholder="请输入质押件数"  disabled/>
                      </FormItem>
                      <FormItem label="红枣品级：" prop="CheckType">
                          <Input v-model="EntryOrderData.CheckType" class="orders_disabled" placeholder="请输入联系电话" disabled/>
                      </FormItem>
                      <!-- 
                      <FormItem label="红枣品级：" prop="TypeClass">
                          <Select v-model="EntryOrderData.TypeClass" placeholder="请选择红枣品级" class="orders_disabled"  disabled style="width:200px;">
                              <Option v-for="item in TypeClassList" :value="item.Id" :key="item.Id">{{ item.TypeClassName }}</Option>
                          </Select>
                      </FormItem>  
                      -->
                      <FormItem label="质押件数：" prop="CheckCount">
                          <InputNumber v-model="EntryOrderData.CheckCount" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 
                      <!--
                      <FormItem label="单价：" prop="UpdateTime">
                          <InputNumber v-model="EntryOrderData.UnitPrice" class="orders_disabled" placeholder="请输入质押件数"  disabled/>
                      </FormItem>   
                      -->
                      <FormItem label="入库地点：" prop="LandingPlace">
                          <Input v-model="EntryOrderData.LandingPlace" class="orders_disabled" placeholder="请输入联系电话" disabled/>
                      </FormItem>
                      <!--
                      <FormItem label="入库地点：" prop="LandingPlace">
                          <Select v-model="EntryOrderData.LandingPlace" placeholder="请选择入库地点" class="orders_disabled"  disabled style="width:200px;">
                              <Option v-for="item in LandingPlaceList" :value="item.Id" :key="item.Id">{{ item.LandingPlaceName }}</Option>
                          </Select>
                      </FormItem>  
                      -->

                      <FormItem label="结算金额：" prop="SumMoney">
                          <InputNumber v-model="EntryOrderData.SumMoney" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 
                                         
                    </Col>

                    <Col span="12">
                      <FormItem label="皮重时间：" prop="UnitPrice">
                          <Input v-model="EntryOrderData.SkinWeightTime" class="orders_disabled" placeholder="请输入皮重时间：" disabled/>
                      </FormItem> 
                      <FormItem label="皮重：" prop="UpdateTime">
                          <InputNumber v-model="EntryOrderData.SkinWeight" class="orders_disabled" placeholder="请输入质押件数"  disabled/>
                      </FormItem> 
                      <FormItem label="结算重量：" prop="AccountWeight">
                          <InputNumber v-model="EntryOrderData.AccountWeight" class="orders_disabled" placeholder="请输入结算"  disabled/>
                      </FormItem> 
                      <FormItem label="装箱类型：" prop="CheckPack">
                          <Input v-model="EntryOrderData.CheckPack" class="orders_disabled" placeholder="请输入联系电话" disabled/>
                      </FormItem>
                      <!--
                      <FormItem label="装箱类型：" prop="CheckPack">
                          <Select v-model="EntryOrderData.CheckPack" class="orders_disabled"  disabled placeholder="请选择装箱类型" style="width:200px;">
                              <Option v-for="item in PackList" :value="item.Id" :key="item.Id">{{ item.PackName }}</Option>
                          </Select>
                      </FormItem>  
                      -->
                      <FormItem label="每件重量：" prop="UpdateTime">
                          <InputNumber v-model="EntryOrderData.UnitWeight" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 
                      <FormItem label="质押件数：" prop="">
                        <label slot="label">&nbsp;&nbsp;&nbsp;&nbsp;</label>
                      </FormItem> 
                      <FormItem label="实付金额：" prop="RealMoney">
                          <InputNumber v-model="EntryOrderData.RealMoney" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <!--
                      <FormItem label="金额：" prop="UpdateTime">
                          <InputNumber v-model="EntryOrderData.SumMoney" class="orders_disabled" placeholder="请输入质押件数"  disabled/>
                      </FormItem> 
                      -->
                    </Col>

                                      
                    <Col span="24">
                        <FormItem>
                          <!--
                            <Button type="primary" :loading="loading" class="buttn_rough"  @click="handleSubmit('EntryOrderData',6)">结算</Button>
                            
                            <Button type="warning" :loading="loading" class="buttn_skin" @click="handleSubmit('EntryOrderData')">称皮重</Button>
                             <Button @click="handleReset('formValidate')" style="margin-left: 8px">重置</Button> -->
                         </FormItem>
                   </Col>
                   
                </div>
              </Form>
        </Row>


        <div slot="footer" >
            <!-- <Button type="error" size="large" long :loading="modal_loading" @click="del">Delete</Button> -->
        </div>
    </Modal>
</div>
</template>

<script>
import {getCompanyList,getDeptList,updateEntryOrderData} from "@/api/data";
import { formatDate } from '../../components/date.js';
export default {
    name: 'Edit',
    data () {
        return {
          loading:false,
          mode:this.edit,
          
          //表单验证规则
          ruleInUser: {

            // UnitPrice: [
            //   { required: true, type:'number',min:2.0, message: '请填写大于或等于2.0的红枣单价', trigger: 'blur' }
            // ],

          //    TypeClass: [
          //     { required: true, type:'number', message: '请选择品级', trigger: 'change' }
          //   ],

          //   CheckPack: [
          //     { required: true, type:'number', message: '请选择装箱类型', trigger: 'change' }
          //   ],

          //   CheckCount: [
          //    { required: true, type:'number',min:2.0, message: '请填写大于或等于2.0的红枣单价', trigger: 'blur' }
          //  ],

            //  LandingPlace: [
            //   { required: true, type:'number', message: '请选择入库地点', trigger: 'change' }
            // ],


          },

           TypeClassList:[
            {
              Id:1,
              TypeClassName:'灰枣一级'
            },
            {
              Id:2,
              TypeClassName:'骏枣一级'
            }
          ],

          LandingPlaceList:[
            {
              Id:1,
              LandingPlaceName:'场地1'
            },
            {
              Id:2,
              LandingPlaceName:'场地2'
            }
          ],

           PackList:[
            {
              Id:1,
              PackName:'箱装'
            },
            {
              Id:2,
              PackName:'框装'
            }
          ],
         
          listdata:[]

        };
    },
    props:{
        edit:{
            type:Boolean ,
            required:true
        },
        EntryOrderData:{
            type:Object,
            required:true 
        },
        


    },
    methods: {
      testChange(val){
        this.$emit('testChange',val);
       },
      cancel(){
           this.loading = false; 
          let data = {
            mode:false
          }
          this.$emit('cancelCallBack', data);
       },
      //提交编辑后的userInfo
      handleSubmit(name,status) {
        
        this.$refs[name].validate(valid => { 
          console.log("提交验证：",valid)    
          if (valid) {  
            this.loading = true;      
            this.submit(status);
          } else {
            this.$Message.error("请填写相关信息!");
          }
        });
      },
    submit(status){
        const data = {
            Id:this.EntryOrderData.Id,
            OrderNo: this.EntryOrderData.OrderNo,
            ApplyTime: this.EntryOrderData.ApplyTime,
            UnitPrice: this.EntryOrderData.UnitPrice,
            CustomerName: this.EntryOrderData.CustomerName,
            LinkTelephone: this.EntryOrderData.LinkTelephone,
            BankName:this.EntryOrderData.BankName,
            BankAccount:this.EntryOrderData.BankAccount,
            PlanType:this.EntryOrderData.PlanType,
            PlanCount:this.EntryOrderData.PlanCount,
            PlanPack:this.EntryOrderData.PlanPack,
            Carrier:this.EntryOrderData.Carrier,
            CarrierTelephone:this.EntryOrderData.CarrierTelephone,
            VehicleNo:this.EntryOrderData.VehicleNo,
            RoughWeightTime:this.EntryOrderData.RoughWeightTime,
            RoughWeight:this.EntryOrderData.RoughWeight,
            SkinWeightTime:this.EntryOrderData.SkinWeightTime,
            SkinWeight:this.EntryOrderData.SkinWeight,
            NetWeight:this.EntryOrderData.NetWeight,
            CheckTime:this.EntryOrderData.CheckTime,
            CheckType:this.EntryOrderData.CheckType,
            CheckClass:this.EntryOrderData.CheckClass,
            CheckPack:this.EntryOrderData.CheckPack,
            CheckCount:this.EntryOrderData.CheckCount,
            UnitWeight:this.EntryOrderData.UnitWeight,
            UnitPrice:this.EntryOrderData.UnitPrice,
            AccountTime:this.EntryOrderData.AccountTime,
            AccountWeight:this.EntryOrderData.AccountWeight,
            SumMoney:this.EntryOrderData.SumMoney,
            RealMoney:this.EntryOrderData.RealMoney,
            Scale:this.EntryOrderData.Scale,
            LandingPlace:this.EntryOrderData.LandingPlace,
            Status:status

    };
      updateEntryOrderData(data).then(res =>{
            if(res == "OK"){
              this.$Message.success("提交成功");
              this.loading = false; 
              let data = {
                mode:false
              }
              this.$emit('success', data);   
            }else if(response.data.flag == 0){
            this.$Message.success("提交失败"); 
            }else if(response.data.flag == 2){
            this.$Message.success("状态过期");
            }
        }).catch(error => {
            this.$Message.error("请核对之后重新提交1");
             this.loading = false; 
       });


     },
    },
    mounted () {
      const cmpdata = {
        fields:"Id,CompanyName",
        offset:"0",
        limit:"-1"
      };
      const dptdata = {
        fields:"Id,DeptName",
        offset:"0",
        limit:"-1"
      };
      //获得包含公司Id和companyname字段的全部列表
      // getCompanyList(cmpdata).then(res =>{
      //   this.CompanyList = res.List;
        
      // });
      //获得包含公司Id和companyname字段的全部列表
      // getDeptList(dptdata).then(res =>{
      //   this.DeptList = res.List;
      // });
    },
    watch: {
        edit(val) {
        this.mode = val
    }
}
}
</script>
<style>
.dept .ivu-select-placeholder{
color:#515a6e!important;
}

.orders_disabled_custom input{
    border:none;
    background-color:#fff!important;
    color:gray!important;
    width: 280px;
}

.buttn_rough{
  width: 100px;
}

.buttn_skin{
  width: 100px;
  margin-left: 150px;
}
</style>